<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="com.util.*"%>

<%
/*
管理员添加后台
*/
DBO db=new DBO();//初始数据库链接
request.setCharacterEncoding("utf-8");//设置字符集
ResultSet rs=null;//声明结果集
	String keyid =(String)request.getParameter("keyid");
String yhm=(String)request.getParameter("yhm");//变量:用户名
String mm=(String)request.getParameter("mm");//变量:密码
String xm=(String)request.getParameter("xm");//变量:姓名

String sql="";//声明sql

int row=1;///定义执行结果
		int num=0;
try{


sql="select count(1) as num from gly where yhm='"+yhm+"'";

rs=db.query(sql);

if(rs.next()){
num=rs.getInt("num");
}

if(num>0){
out.println("<script>");
out.println("alert('操作失败,用户名重复');");
out.println("window.location='glyadd.jsp'");
out.println("</script>");

return;
}


	 sql="insert into gly(yhm,mm,xm) values('"+yhm+"','"+mm+"','"+xm+"')";
;//管理员SQL 语句
		//int row =0;
		row=db.update(sql);
}catch(Exception e){
System.out.println(e.toString());}
if(row==1){
out.println("<script>");
out.println("alert('操作成功');");
out.println("window.location='glyadd.jsp'");
out.println("</script>");
}else{
out.println("<script>");
out.println("alert('操作失败');");
out.println("window.location='glyadd.jsp'");
out.println("</script>");
}
db.close();
%>

